package com.ukao.cashregister.pesenter;

import android.content.Context;

import com.ukao.cashregister.base.BasePresenter;
import com.ukao.cashregister.bean.OrdersList;
import com.ukao.cashregister.consts.Constant;
import com.ukao.cashregister.consts.SaveParamets;
import com.ukao.cashregister.retrofit.ApiCallback;
import com.ukao.cashregister.utils.L;
import com.ukao.cashregister.view.OrderlistView;

import java.util.HashMap;

/**
 * Created by ukaodev on 2017/6/26.
 */

public class OrderListPesenter extends BasePresenter<OrderlistView> {

    public OrderListPesenter(OrderlistView view) {
        attachView(view);
    }








    /**
     *  取件订单列表
     * @param mContext

     */
    public void takeList(Context  mContext,String  searchValue,String  userId,int pageNum,int  pageSize) {
        L.i("searchValue="+searchValue);
        HashMap mHashMap=new HashMap<String,String>();
        mHashMap.put("searchValue",searchValue) ;
        mHashMap.put("userId",userId) ;
        mHashMap.put("pageNum",pageNum+"");
        mHashMap.put("pageSize",pageSize+"");
        mHashMap.put("accessToken", SaveParamets.getToken(mContext));
        addSubscription(apiStores.takeList(Constant.createParameter(mHashMap)),
                new ApiCallback<OrdersList>() {
                    @Override
                    public void onSuccess(OrdersList model) {

                        if (model.getHttpCode()== 200) {

                           mvpView.loadSuccess(model.getData());

                        }else{
                              mvpView.loadFail(model.getMsg());

                        }
                    }




                    @Override
                    public void onFinish() {

                    }
                });
    }






}
